package 力扣日常刷题.木23一月.第15天315;

/**
 * @author 帅小伙
 * @date 2022/3/15
 * @description
 */
public class Demo71验证ipv4 {

    public boolean isIPV4(String ipv4) {
        String[] split = ipv4.split("\\.");
        if(split.length != 4) return false;
        for (String s : split) {
            try{
                if(Integer.parseInt(s) < 0 && Integer.parseInt(s) > 255){
                    return false;
                }
            }catch (Exception e){
                return false;
            }
            if(Integer.parseInt(s) == 0 && s.length() != 1){
                return false;
            }
        }
        return true;
    }

}
